using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Data.SqlClient;
/// <summary>
/// Summary description for HuongNghienCuuDAO
/// </summary>
public class HuongNghienCuuDAO:DataProvider
{
    public ArrayList LayMang_HuongNC()
    {
        connect();
        ArrayList arr = new ArrayList();
        try
        {
            SqlCommand cmd = new SqlCommand("sp_Select_HuongNghienCuu", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                HuongNghienCuuDTO hncdto = new HuongNghienCuuDTO();
                hncdto.MaHuongNC = dr.GetInt32(0);
                hncdto.HuongNC = dr.GetString(1);                
                arr.Add(hncdto);
            }
        }
        catch (Exception es)
        {
            throw es;
        }
        return arr;
    }
    public void insert(HuongNghienCuuDTO hncdto)
    {
        connect();

        try
        {
            SqlCommand cmd = new SqlCommand("sp_Insert_HuongNghienCuu", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@huongnc", SqlDbType.NVarChar);
            cmd.Parameters["@huongnc"].Value = hncdto.HuongNC.ToString();
            cmd.Parameters["@huongnc"].Direction = ParameterDirection.Input;
            cmd.ExecuteNonQuery();
        }
        catch (Exception es)
        {
            throw es;
        }
    }
    public void update(HuongNghienCuuDTO hncdto)
    {
        connect();
        try
        {
            SqlCommand cmd = new SqlCommand("sp_Update_HuongNghienCuu", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@mahnc", SqlDbType.Int);
            cmd.Parameters["@mahnc"].Value = hncdto.MaHuongNC;
            cmd.Parameters["@mahnc"].Direction = ParameterDirection.Input;

            cmd.Parameters.Add("@huongnc", SqlDbType.NVarChar);
            cmd.Parameters["@huongnc"].Value = hncdto.HuongNC.ToString();
            cmd.Parameters["@huongnc"].Direction = ParameterDirection.Input;

            cmd.ExecuteNonQuery();


        }
        catch (System.Exception ex)
        {
            throw ex;
        }
    }
	public HuongNghienCuuDAO()
	{
		//
		// TODO: Add constructor logic here
		//
	}
}
